﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace PVAutoTest.LibCommon
{
    public class ProjectDefine
    {
        public enum MsgType_e { 
            MSG_UNKNOWN = -1,

            //for Simulator
            MSG_EVENT_FINISHED = 10,

            //for TestSuit
            MSG_CASE_FINISHED = 20,
        }

        public enum TCResult_e {
            TC_UNKNOWN = -1,

            TC_PASSED = 1,
            TC_FAILED,
            TC_ERROR,
        }

        public enum TCCheckPoints_e {
            CP_UNKNOWN = 0,

            CP_DATABASE = 1,
            CP_TRACE = 2,
            CP_LOG = 4,
        }

        public static string AgmIp;
        public static int AgmPort;
        public static string ConnStr;

        /// <summary>
        /// 清空容器中各控件缓存的值
        /// </summary>
        /// <param name="container">容器类控件</param>
        public static void clear_values(Control container)
        {
            for (int i = 0; i < container.Controls.Count; i++)
            {

                //如果是容器类控件 递归调用自己
                if (container.Controls[i].HasChildren)
                {
                    clear_values(container.Controls[i]);
                }
                else
                {
                    string name = container.Controls[i].GetType().Name;
                    switch (container.Controls[i].GetType().Name)
                    {
                        case "TextBox":
                            container.Controls[i].Text = "";
                            break;
                        case "RadioButton":
                            ((RadioButton)(container.Controls[i])).Checked = false;
                            break;
                        case "CheckBox":
                            ((CheckBox)(container.Controls[i])).Checked = false;
                            break;
                        case "ComboBox":
                            ((ComboBox)(container.Controls[i])).SelectedItem = null;
                            break;
                        case "CheckedListBox":
                            {
                                int count = ((CheckedListBox)(container.Controls[i])).Items.Count;
                                for (int j = 0; j < count; j++) {
                                    ((CheckedListBox)(container.Controls[i])).SetItemChecked(j, false);
                                }
                            }
                            break;
                        default:
                            break;
                    }
                }
            }
        }

    }
}
